package AircraftDesignKg.controller;
import AircraftDesignKg.server.ServiceImpl;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 设计文档解析请求入口
 * Author: congwey
 */
@RestController
public class ParseDocumentController {

    private static final Logger log = LogManager.getLogger(ParseDocumentController.class);

    @Autowired
    private ServiceImpl deepSeekService;

    @PostMapping("/process-file")
    public ResponseEntity<String> processFile(@RequestParam("file") MultipartFile file) {
        try {
            String result = deepSeekService.callAPI(file);
            log.info("[info] 处理成功");
            return ResponseEntity.ok(result);
        } catch (Exception e) {
            log.error("[error] 处理失败: {}", e.getMessage());
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
                                 .body("处理失败: " + e.getMessage());
        }
    }

}